#!/usr/bin/env python
# -*- coding: utf-8 -*-

# date 20210426

# 监听本机的端口
bind = "0.0.0.0:8000"
# 未决连接的最大数量，即等待服务的客户的数量
backlog = 2048
# 进程数
workers = 4
# 线程数
threads=2
# 工作模式为gevent
worker_class = 'gevent'
# 最大客户端并发数量，默认情况下这个值为1000。
worker_connections = 10000
# 超时 默认30秒
timeout = 10
# 连接上等待请求的秒数，默认情况下值为2
keepalive = 2
# 根目录
chdir = './'
# 日志格式
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'loggers': {
        "gunicorn.error": {
            "level": "DEBUG",  # 打日志的等级可以换的，下面的同理
            "handlers": ["error_file"],  # 对应下面的键
            "propagate": 1,
            "qualname": "gunicorn.error"
        },

        "gunicorn.access": {
            "level": "DEBUG",
            "handlers": ["access_file"],
            "propagate": 0,
            "qualname": "gunicorn.access"
        }
    },
    'handlers': {
        "error_file": {
            "class": "logging.handlers.RotatingFileHandler",
            "maxBytes": 1024 * 1024 * 1024,  # 打日志的大小，我这种写法是1个G
            "backupCount": 1,  # 备份多少份，经过测试，最少也要写1，不然控制不住大小
            "formatter": "generic",  # 对应下面的键
            # 'mode': 'w+',
            "filename": "error.log"  # 打日志的路径
        },
        "access_file": {
            "class": "logging.handlers.RotatingFileHandler",
            "maxBytes": 1024 * 1024 * 1024,
            "backupCount": 1,
            "formatter": "generic",
            "filename": "access.log",
        }
    },
    'formatters': {
        "generic": {
            "format": "'[%(process)d] [%(asctime)s] %(levelname)s [%(filename)s:%(lineno)s] %(message)s'",  # 打日志的格式
            "datefmt": "[%Y-%m-%d %H:%M:%S %z]",  # 时间显示方法
            "class": "logging.Formatter"
        },
        "access": {
            "format": "'[%(process)d] [%(asctime)s] %(levelname)s [%(filename)s:%(lineno)s] %(message)s'",
            "class": "logging.Formatter"
        }
    }
}